/* 
 * File:   icon.h
 * Author: cow
 *
 * Created on February 10, 2011, 9:39 PM
 */

#ifndef _ICON_H
#define	_ICON_H

//includes-----------------------------
#include <gtkmm/container.h>
#include <gtkmm/widget.h>
#include <gdkmm/event.h>
#include <gtkmm/image.h>
#include <glibmm/refptr.h>
#include <cairomm/context.h>
#include <queue>
#include <vector>
#include <string>
using namespace std;
//defines------------------------------
//prototypes---------------------------
namespace Icons{
class icon;
class imageIcon;
class vectorIcon;
class iconLib;

class iconComp;
class iconContainer;
}
//definitions--------------------------
namespace Icons{
class icon : public Gtk::Widget{
        public:
            //manipulators
            void zLevel(int _z){z = _z;}
            int  zLevel(){return z;}
            virtual void draw(Cairo::RefPtr<Cairo::Context> cr, int x, int y) = 0;
        protected:
            int z;
        private:
};
class imageIcon : public icon{
    public:
        //constructs
        imageIcon(int _zlevel = 0);
        imageIcon(string fileLoc,  int _zlevel = 0);
        imageIcon(Cairo::RefPtr<Cairo::ImageSurface> _img, int _zlevel = 0);
        ~imageIcon();
        //manips
        void setImage(string fileLoc);
        void setImage(Cairo::RefPtr<Cairo::ImageSurface> neImg, int x, int y);
        virtual void draw(Cairo::RefPtr<Cairo::Context> cr);
    private:
        Cairo::RefPtr<Cairo::ImageSurface> img;
};
class vectorIcon : public icon{
    public:
        //constructs
        vectorIcon();
        vectorIcon(int vnum, int* verts);
        ~vectorIcon();
        //manips
        void vectorList(int vnum, int* verts);
        void vectorList(vector<int>* verts);
        virtual void draw();
    protected:
    private:
        vector<int> verts;
};
class iconLib{
    public:
        //constructs
        iconLib();
        iconLib(string fileLoc);
        ~iconLib();
        //access
        const icon* requestIcon(int id);
        int  addIcon(icon* icn);
    protected:
    private:
        int nextFreeId;
        map<int ,icon*> icons;
};
class iconComp{
    public:
        iconComp();
        bool operator() (icon* first, icon* second);
};
class iconContainer : public Gtk::Widget{
        public:
            //constructors
            iconContainer();
            ~iconContainer();
            //manips
            int addIcon(icon* addme);
            void removeIcon(int iconid);
        protected:

        private:
            priority_queue<icon*, vector<icon*>, iconComp> zorder;
            icon* bg;
};
}
#endif	/* _ICON_H */

